<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>dimension-type-config-add</title>
		<%@ include file="../include/common.jsp"%>
		<%@ include file="../include/form.jsp"%>
		<script type="text/javascript">
  
  function add(){
	//校验(url+账号)是否唯一
	  $.ajax({
		   type: "POST", 
		   url: "${pageContext.request.contextPath}/config/dimension-type-config!validateDimensionTypeName.action", //请求的action
		   data: "dimensionTypeName="+$("#dimensionTypeName").val()+"&isValideFlag="+"true", //传的参数
		   dataType: 'json',
		   success: function(data){ //结果
			   if(data == true){
				   //提交
					 $.ajax({
						   type: "POST", 
						   url: "${pageContext.request.contextPath}/config/dimension-type-config!save.action", //请求的action
						   data: $("#myform").serialize(), //传的参数
						   dataType: 'json',
						   success: function(data){ //结果
							   if(data == true){
								   var pWin = getTopWin(window).currentWin["dimension-type-config-common"];
								   pWin.datagrid();
								   getTopWin(window).closejBox("dimension-type-config-add");
							   }
						   }
					});
			   }else{
				   getTopWin(window).getMessageBox().alert("您添加的维度类型已经存在","提示");
			   }
		   }
	});
  }
    $(function(){
	  $.formValidator.initConfig({formid:"myform"
          ,onerror:function(msg){}
          ,onsuccess:function(){
        	  		add();
          			return false;
          }
      });
	  $("#dimensionTypeName").formValidator({onshow:"请输入字符串 长度(1-32)",onfocus:"请输入字符串 长度(1-32)",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"不能为空"}).inputValidator({empty:{leftempty:false,rightempty:false,emptyerror:"两边不能有空格"},onerror:"不能为空"})
	  .functionValidator({
			    fun:function(val,elem){
			    	    if(val.replace(/[^\x00-\xff]/g, "xx").length > 32){
			    	        return "长度超出最大范围";
			    	    }
			    	    return true;
				}
	  });
  });
   function closewin(){
	   getTopWin(window).closejBox("dimension-type-config-add");
   }

  
  </script>
	</head>

	<body class="padding-8">
		<form action="" id="myform" name="myform" method="post">
			<table class="table_eidt">
				<tr>
					<td class="td_left" width="120px">
						<span class="span_alert">*</span>维度类型名称
					</td>
					<td class="td_right">
						<input type="text" name="dimensionTypeName" id="dimensionTypeName"
						class="input_text" />
						<span id="dimensionTypeNameTip" style="width: 150px"></span>
					</td>
				</tr>
			  <tr>
					<td class="td_left" width="120px">
						<span class="span_alert">*</span>维度层级
					</td>
					<td class="td_right">
						<input type="radio" name="isRelation" id="isRelation"
						 value="0" checked="checked" />一层
						<input type="radio" name="isRelation" id="isRelation"
						value="1" />多层
					</td>
				</tr>
			</table>
			<div align="center" style="margin-top: 9px;">
				<input type="submit" id="button" name="button" value="保存"
					class="btn-4">
				<input type="reset" class="btn-4">
				<input type="button" value="取消" onclick="closewin();" class="btn-4">
			</div>
		</form>
	</body>
</html>
